package com.front.managementfront.customers.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.front.managementfront.customers.entity.Customers;
import com.front.managementfront.customers.mapper.CustomersMapper;
import com.front.managementfront.customers.service.ICustomersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
import java.util.stream.Collectors;

import static com.front.managementfront.customers.entity.Customers.ENABLE;

/**
 * <p>
 * 客服表 服务实现类
 * </p>
 *
 * @author hml
 * @since 2021-09-02
 */
@Service
@Transactional
public class CustomersServiceImpl extends ServiceImpl<CustomersMapper, Customers> implements ICustomersService {


    @Autowired
    private CustomersMapper customersMapper;

    @Override
    public IPage<Customers> selectPage(Page<Customers> page, Customers customers) {
        QueryWrapper<Customers> query = Wrappers.query();
        return customersMapper.selectPage(page, query);
    }


    @Override
    public List<String> selectList() {
        QueryWrapper<Customers> query = Wrappers.query();
        query.lambda().eq(Customers::getIsEnable, ENABLE);
        List<Customers> customers=customersMapper.selectList(query);
        return customers.stream().map(Customers::getMobile).collect(Collectors.toList());
    }

    /**
     * 公共查询条件
     *
     * @param entityWrapper
     * @return
     */
    public QueryWrapper<Customers> getEntityWrapper(QueryWrapper<Customers> entityWrapper, Customers customers) {
        //条件拼接

        return entityWrapper;
    }
}
